|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DomEJBDDParser.java | 50% | 76.2% | 75% | 72.4% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
|
|
17 |
package org.apache.geronimo.ews.ws4j2ee.parsers;
|
|
18 |
|
|
19 |
import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
|
|
20 |
import org.apache.geronimo.ews.ws4j2ee.context.impl.EJBDDContextImpl;
|
|
21 |
import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
|
|
22 |
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
|
23 |
import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
|
|
24 |
import org.w3c.dom.Document;
|
|
25 |
import org.w3c.dom.Element;
|
|
26 |
import org.w3c.dom.NodeList;
|
|
27 |
|
|
28 |
import java.io.InputStream;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Parse the ejb-jar.xml file and get the name of the EJB
|
|
32 |
*
|
|
33 |
* @author Srinath Perera(hemapani@opensource.lk)
|
|
34 |
*/
|
|
35 |
public class DomEJBDDParser { |
|
36 |
private J2EEWebServiceContext j2eewscontext;
|
|
37 |
private String ejbName = null; |
|
38 |
private EJBContext context;
|
|
39 |
|
|
40 | 9 |
public DomEJBDDParser(J2EEWebServiceContext j2eewscontext) {
|
41 | 9 |
this.j2eewscontext = j2eewscontext;
|
42 |
} |
|
43 |
|
|
44 | 9 |
public void parse(InputStream inputStream) throws GenerationFault { |
45 | 9 |
try {
|
46 | 9 |
Document doc = Utils.createDocument(inputStream); |
47 | 9 |
Element root = doc.getDocumentElement(); |
48 | 9 |
NodeList beaneles = root.getElementsByTagName("enterprise-beans");
|
49 | 9 |
if (beaneles.getLength() > 0) {
|
50 | 9 |
Element beanele = (Element) beaneles.item(0); |
51 | 9 |
NodeList sessionList = beanele.getElementsByTagName("session");
|
52 | 9 |
if (sessionList.getLength() > 0) {
|
53 | 9 |
Element session = (Element) sessionList.item(0); |
54 | 9 |
String ejbName = Utils.getElementValue(session.getElementsByTagName("ejb-name"));
|
55 | 9 |
String home = Utils.getElementValue(session.getElementsByTagName("home"));
|
56 | 9 |
String remote = Utils.getElementValue(session.getElementsByTagName("remote"));
|
57 | 9 |
String ejbClass = Utils.getElementValue(session.getElementsByTagName("ejb-class"));
|
58 | 9 |
context = new EJBDDContextImpl(ejbName,
|
59 |
ejbClass, |
|
60 |
home, remote, null, null); |
|
61 |
} else {
|
|
62 | 0 |
throw new GenerationFault("session tag not found"); |
63 |
} |
|
64 |
} else {
|
|
65 | 0 |
throw new GenerationFault("enterprise-beans tag not found"); |
66 |
} |
|
67 |
} catch (Exception e) {
|
|
68 | 0 |
e.printStackTrace(); |
69 | 0 |
throw GenerationFault.createGenerationFault(e);
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
/**
|
|
74 |
* @return
|
|
75 |
*/
|
|
76 | 8 |
public EJBContext getContext() {
|
77 | 8 |
return context;
|
78 |
} |
|
79 |
|
|
80 |
/**
|
|
81 |
* @param context
|
|
82 |
*/
|
|
83 | 0 |
public void setContext(EJBContext context) { |
84 | 0 |
this.context = context;
|
85 |
} |
|
86 |
|
|
87 |
} |
|
88 |
|
|